#include "casideexception.h"

/**
 * CAsideException - creates default exception
 */
CAsideException::CAsideException() {
  message = "";
  exClassName = "";
  exMethodName = "";
  cause = NULL;
}
//---------------------------------------------------------------------------

/**
 * CAsideException - creates exception with specified message
 * @param message
 */
CAsideException::CAsideException(string message) {
  this->message = message;
  this->exClassName = "";
  this->exMethodName = "";
  this->cause = NULL;
}
//---------------------------------------------------------------------------

/**
 * CAsideException - creates exception
 * @param exClassName class in which exception has been rised
 * @param exMethodName method in which exception has been rised
 * @param message
 */
CAsideException::CAsideException(string exClassName, string exMethodName,
                                 string message) {
  this->message = message;
  this->exClassName = exClassName;
  this->exMethodName = exMethodName;
  this->cause = NULL;
}
//---------------------------------------------------------------------------

/**
 * CAsideException - konstruktor
 * @param exClassName class in which exception has been rised
 * @param exMethodName method in which exception has been rised
 * @param message
 * @param cause exception cause
 */
CAsideException::CAsideException(string exClassName, string exMethodName,
                                 string message, CAsideException* cause) {
  this->message = message;
  this->exClassName = exClassName;
  this->exMethodName = exMethodName;
  this->cause = cause;
}
//---------------------------------------------------------------------------

/**
 * getExClassName - returns name of class in which exception has been rised
 * @return classname
 */
string CAsideException::getExClassName() const {
  return exClassName;
}
//---------------------------------------------------------------------------

/**
 * getExMethodName - returns name of method in which exception has been rised
 * @return name
 */
string CAsideException::getExMethodName() const {
  return exMethodName;
}
//---------------------------------------------------------------------------

/**
 * getMessage - returns exception message
 * @return message
 */
string CAsideException::getMessage() const {
  return message;
}
//---------------------------------------------------------------------------

/**
 * getCause - returns exception cause
 * @return cause
 */
CAsideException* CAsideException::getCause() const {
  return cause;
}
//---------------------------------------------------------------------------

/**
 * toString - converts exception to string
 * @return exception as string
 */
string CAsideException::toString() const {
  return "exception '" + getClassName() + "' throwed"
         + (strcmp(exClassName.c_str(), "") != 0 ? " in file: '"
            + exClassName + "'" : "")
         + (strcmp(exMethodName.c_str(), "") != 0 ? " in method: '"
            + exMethodName + "'" : "")
         + (cause != NULL ? " with cause: '" + cause->getClassName() + "'" : "")
         + (strcmp(message.c_str(), "") != 0 ? " message: '" + message
            + "'" : "");
}
//---------------------------------------------------------------------------
